package com.starinside.wp.controller.api;

import com.starinside.wp.foundation.model.StatusResponse;
import com.starinside.wp.utils.HttpClient;
import com.starinside.wp.utils.JsonUtil;
import com.starinside.wp.utils.RemoteCallUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static com.starinside.wp.foundation.constant.RequestConstant.TICKET;


@RestController
@RequestMapping("/estimate/teacher")
@Api(tags = "老师评价")
class TeacherEstimateApiController {


    @Value("${teach.server.url}")
    private String teacherServerURL;



    /**
     * 获取老师评价列表
     */
    @PostMapping("/getList")
    public StatusResponse getList(@RequestBody Map<String,Object> mapTeacher ) throws IOException {
        String s = HttpClient.doPost(teacherServerURL + "/api/estimate/teacher/postList",mapTeacher);
        Map map = JsonUtil.readToMap(s);
        return StatusResponse.success(map.get("data"));
    }


    /**
     * 新增老师评价列表
     */
    @PostMapping("/add")
    public StatusResponse add(@RequestBody Map<String,Object> mapTeacher ) throws IOException {
        String s = HttpClient.doPost(teacherServerURL + "/api/estimate/teacher/add",mapTeacher);
        Map map = JsonUtil.readToMap(s);
        return StatusResponse.success(map.get("data"));
    }




    /**
     * 修改老师评价列表
     */
    @PostMapping("/update")
    public Map update(@RequestBody Map<String, Object> aboutPallet) throws IOException {
        String json = HttpClient.doPost(teacherServerURL + "/api/estimate/teacher/update",aboutPallet);
        Map map = JsonUtil.readToMap(json);
        return map;
    }


    /**
     * 修改老师评价列表
     */
    @PostMapping("/getById")
    public Map getById(@RequestBody Map<String, Object> aboutPallet) throws IOException {
        String json = HttpClient.doPost(teacherServerURL + "/api/estimate/teacher/getById",aboutPallet);
        Map map = JsonUtil.readToMap(json);
        return map;
    }


}
